import Mock from 'mockjs'

// APP流量跟踪数据
export const mockAppTrafficTrack = () => {
  Mock.mock(/\/api\/app\/track/, 'get', (options) => {
    // 解析 URL 参数
    const url = new URL(options.url, window.location.origin)
    const params = Object.fromEntries(url.searchParams)

    // 这里可以使用参数来模拟不同的数据场景
    return {
      code: 200,
      message: 'success',
      data: {
        legends: ['抖音', '快手', '小红书', 'B站', '微信'],
        xaxisData: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
        seriesData: [
          [120, 132, 101, 134, 90, 230, 210],
          [220, 182, 191, 234, 290, 330, 310],
          [150, 232, 201, 154, 190, 330, 410],
          [320, 332, 301, 334, 390, 330, 320],
          [820, 932, 901, 0, 1290, 1330, 1320],
        ],
      },
    }
  })
}

/*
// APP流量排名数据
export const mockAppTrafficRank = () => {
  Mock.mock(/\/api\/app\/traffic-rank/, 'get', (options) => {
    const url = new URL(options.url, window.location.origin)
    const params = Object.fromEntries(url.searchParams)

    // 基础数据 - 按流量大小降序排列
    const baseData = {
      names: ['PPT视频', '王者荣耀', '抖音短视频', '快手短视频', '微博国际版'],
      values: {
        ALL: [25000, 18000, 12000, 10000, 8000],
        '4G': [15000, 10800, 7200, 6000, 4800],
        '3G': [7500, 5400, 3600, 3000, 2400],
        '2G': [2500, 1800, 1200, 1000, 800]
      },
      colors: ['#FF7F50', '#87CEEB', '#DDA0DD', '#90EE90', '#FFB6C1']  // 为每个APP设置固定颜色
    }

    // 根据网络制式返回对应数据
    const networkType = params.networkType || 'ALL'
    const seriesData = [baseData.values[networkType]]

    return {
      code: 200,
      message: 'success',
      data: {
        legends: baseData.names,  // 使用APP名称作为图例
        xAxisData: baseData.names,
        seriesData,
        colors: baseData.colors  // 添加颜色数据
      }
    }
  })
}
*/


// APP流量排名数据
export const mockAppTrafficRank = () => {
  // 柱状图数据接口
  Mock.mock(/\/api\/app\/traffic-rank/, 'get', () => {
    const data = {
      names: ['PPT视频', '王者荣耀', '抖音短视频', '快手短视频', '微博国际版'],
      values: {
        ALL: [25000, 18000, 12000, 10000, 8000],
        WIFI: [15000, 10800, 7200, 6000, 4800],
        MOBILE: [10000, 7200, 4800, 4000, 3200]
      }
    }

    return {
      code: 200,
      message: 'success',
      data: {
        legends: ['ALL', 'WIFI', 'MOBILE'],
        xAxisData: data.names,
        seriesData: [
          data.values.ALL,
          data.values.WIFI,
          data.values.MOBILE
        ]
      }
    }
  })

  // 饼图数据接口
  Mock.mock(/\/api\/app\/traffic-pie/, 'get', () => {
    const data = {
      names: ['PPT视频', '王者荣耀', '抖音短视频', '快手短视频', '微博国际版'],
      values: [25000, 18000, 12000, 10000, 8000],
      colors: ['#FF7F50', '#87CEEB', '#DDA0DD', '#90EE90', '#FFB6C1']
    }

    return {
      code: 200,
      message: 'success',
      data: {
        names: data.names,
        values: data.values,
        colors: data.colors
      }
    }
  })
}

// 新增地图数据API
export const mockAppTrafficMap = () => {
  Mock.mock(/\/api\/app\/map/, 'get', (options) => {
    return {
      code: 200,
      message: 'success',
      data: [
          { name: '抖音', longitude: 116.46, latitude: 39.92, value1: 340 },
          { name: '淘宝', longitude: 121.48, latitude: 31.22, value1: 280 },
          { name: '微信', longitude: 113.23, latitude: 23.16, value1: 250 },
          // ... 更多数据
        ]
    }
  })
}

// 新增排名数据API
export const mockAppaaaTrafficRank = () => {
  Mock.mock(/\/api\/app\/rank/, 'get', (options) => {
    return {
      code: 200,
      message: 'success',
      data: {
        appNames: ['抖音', '淘宝', '微信', '快手', 'B站'],
        networkData: {
          all: [320, 302, 301, 334, 390],
          g4: [220, 182, 191, 234, 290],
          g3: [150, 232, 201, 154, 190],
          g2: [98, 77, 101, 99, 40]
        }
      }
    }
  })
}

// 修改分布数据API
export const mockAppTrafficDistribution = () => {
    Mock.mock(/\/api\/app\/distribution/, 'get', (options) => {
      const data = {
        '抖音': [
          { coord: [120.123, 30.240,], value: 53 },
          { coord: [120.124, 30.241], value: 64 },
          { coord: [120.125, 30.242], value: 41 },
          { coord: [120.126, 30.243], value: 82 },
          { coord: [120.127, 30.244], value: 45 },
          { coord: [120.128, 30.245], value: 68 },
          { coord: [120.129, 30.246], value: 39 },
          { coord: [120.130, 30.247], value: 75 },
          { coord: [120.131, 30.248], value: 50 },
          { coord: [120.132, 30.249], value: 39 },
          { coord: [120.133, 30.250], value: 65 },
          { coord: [120.134, 30.251], value: 60 },
          { coord: [120.135, 30.252], value: 54 },
          { coord: [120.136, 30.253], value: 41 },
          { coord: [120.137, 30.254], value: 83 },
          { coord: [120.138, 30.255], value: 91 },
          { coord: [120.139, 30.256], value: 72 },
          { coord: [120.140, 30.257], value: 44 },
          { coord: [120.141, 30.258], value: 66 },
          { coord: [120.142, 30.259], value: 51 },
          { coord: [120.143, 30.260], value: 38 },
          { coord: [120.144, 30.261], value: 61 },
          { coord: [120.145, 30.262], value: 73 },
          { coord: [120.146, 30.263], value: 55 },
          { coord: [120.147, 30.264], value: 49 },
          { coord: [120.148, 30.265], value: 62 },
          { coord: [120.149, 30.266], value: 78 },
          { coord: [120.150, 30.267], value: 54 },
          { coord: [120.151, 30.268], value: 69 },
          { coord: [120.152, 30.269], value: 81 },
          { coord: [120.153, 30.270], value: 56 },
          { coord: [120.154, 30.271], value: 47 },
          { coord: [120.155, 30.272], value: 72 },
          { coord: [120.156, 30.273], value: 65 },
          { coord: [120.157, 30.274], value: 54 },
          { coord: [120.158, 30.275], value: 49 },
          { coord: [120.159, 30.276], value: 39 },
          { coord: [120.160, 30.277], value: 58 },
          { coord: [120.161, 30.278], value: 62 },
          { coord: [120.162, 30.279], value: 70 },
          { coord: [120.163, 30.280], value: 44 },
          { coord: [120.164, 30.281], value: 60 },
          { coord: [120.165, 30.282], value: 50 },
          { coord: [120.166, 30.283], value: 46 },
          { coord: [120.167, 30.284], value: 75 },
          { coord: [120.168, 30.285], value: 62 },
          { coord: [120.169, 30.286], value: 69 },
          { coord: [120.170, 30.287], value: 61 },
          { coord: [120.171, 30.288], value: 71 },
          { coord: [120.172, 30.289], value: 63 },
          { coord: [120.173, 30.290], value: 68 },
          { coord: [120.174, 30.291], value: 79 },
          { coord: [120.175, 30.292], value: 47 },
        ],
        '快手': [
          { coord: [120.150, 30.250], value: 53 },
          { coord: [120.151, 30.251], value: 64 },
          { coord: [120.152, 30.252], value: 41 },
          { coord: [120.153, 30.253], value: 82 },
          { coord: [120.154, 30.254], value: 45 },
          { coord: [120.155, 30.255], value: 68 },
          { coord: [120.156, 30.256], value: 39 },
          { coord: [120.157, 30.257], value: 75 },
          { coord: [120.158, 30.258], value: 50 },
          { coord: [120.159, 30.259], value: 39 },
          { coord: [120.160, 30.260], value: 65 },
          { coord: [120.161, 30.261], value: 60 },
          { coord: [120.162, 30.262], value: 54 },
          { coord: [120.163, 30.263], value: 41 },
          { coord: [120.164, 30.264], value: 83 },
          { coord: [120.165, 30.265], value: 91 },
          { coord: [120.166, 30.266], value: 72 },
          { coord: [120.167, 30.267], value: 44 },
          { coord: [120.168, 30.268], value: 66 },
          { coord: [120.169, 30.269], value: 51 },
          { coord: [120.170, 30.270], value: 38 },
          { coord: [120.171, 30.271], value: 61 },
          { coord: [120.172, 30.272], value: 73 },
          { coord: [120.173, 30.273], value: 55 },
          { coord: [120.174, 30.274], value: 49 },
          { coord: [120.175, 30.275], value: 62 },
          { coord: [120.176, 30.276], value: 78 },
          { coord: [120.177, 30.277], value: 54 },
          { coord: [120.178, 30.278], value: 69 },
          { coord: [120.179, 30.279], value: 81 },
          { coord: [120.180, 30.280], value: 56 },
          { coord: [120.181, 30.281], value: 47 },
          { coord: [120.182, 30.282], value: 72 },
          { coord: [120.183, 30.283], value: 65 },
          { coord: [120.184, 30.284], value: 54 },
          { coord: [120.185, 30.285], value: 49 },
          { coord: [120.186, 30.286], value: 39 },
          { coord: [120.187, 30.287], value: 58 },
          { coord: [120.188, 30.288], value: 62 },
          { coord: [120.189, 30.289], value: 70 },
          { coord: [120.190, 30.290], value: 44 },
          { coord: [120.191, 30.291], value: 60 },
          { coord: [120.192, 30.292], value: 50 },
        ]
      }

      return {
        code: 200,
        message: 'success',
        data: data
      }
    })
}

